enum-as-inner
A deriving proc-macro for generating functions to automatically give access to the inner members of enum.
Basic unnamed field case
The basic case is meant for single item enums, like:
use EnumAsInner;
where the inner item can be retrieved with the as_*()
/as_*_mut()
or with the into_*()
functions:
let one = One;
assert_eq!;
assert_eq!;
let mut one = One;
assert_eq!;
assert_eq!;
assert_eq!;
where the result is either a reference for inner items or a tuple containing the inner items.
Unit case
This will return true if enum's variant matches the expected type
use EnumAsInner;
let unit = Two;
assert!;
Mutliple, unnamed field case
This will return a tuple of the inner types:
use EnumAsInner;
And can be accessed like:
let mut many = Three;
assert_eq!;
assert_eq!;
assert_eq!;
Multiple, named field case
This will return a tuple of the inner types, like the unnamed option:
use EnumAsInner;
And can be accessed like:
let mut many = Three;
assert_eq!;
assert_eq!;
assert_eq!;